package com.atguigu.juc.day03.collection;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;

public class Demo02Set {

    public static void main(String[] args) {

        Set<String> set =
                // new HashSet<>();
                // Collections.synchronizedSet(new HashSet<>());
                new CopyOnWriteArraySet<>();

        for (int i = 0; i < 10; i++) {
            new Thread(()->{

                for (int j = 0; j < 10; j++) {
                    String data = UUID.randomUUID().toString().replace("-", "").toUpperCase().substring(0, 5);
                    set.add(data);
                    System.out.println(set);
                }

            }, "thread-" + i).start();
        }

    }

}
